{include "INC_header.html" title="资产类型配置"}
<div class="app-outlet" id="app-outlet">
    <!-- ant-design 应用需要配置 -->
    <a-config-provider :locale="configs.locale" :theme="configs.theme">
        <div class="app-container"></div>
    </a-config-provider>
</div>
<script>
    //vue app
    const { createApp } = Vue;
    const { message } = antd;
    const app = createApp({
        data() {
            return {
                //主题配置
                configs: appProviderConfig,
                //数据
                config: {
                    cache: false,
                    cacheTime: 86400,
                    illegalString: ''
                },
                php: 'php',
                name: 'admin',
                saveLoading: false
            }
        },
        mounted() {
            //挂载成功
            const hide = message.loading("正在加载配置...");
            let self = this;
            axios.get("{url url='/cms/api/config'}").then(({ data }) => {
                hide();
                if (data.error === 0) {
                    self.config = data.data;
                } else {
                    message.error(data.message);
                }
            }).catch(() => {
                hide();
                message.error("服务端繁忙");
            });
        },
        methods: {
            //方法
            save: function () {
                if (this.saveLoading) {
                    return;
                }
                this.saveLoading = true;
                let self = this;
                axios.post("{url url='/cms/api/config/save'}", {
                    //原文提交过去
                    config: this.config
                }).then(({ data }) => {
                    self.saveLoading = false;
                    if (data.error === 0) {
                        message.success(data.message);
                    } else {
                        message.error(data.message);
                    }
                }).catch(() => {
                    self.saveLoading = false;
                    message.error("服务端繁忙");
                });
            }
        }
    }).use(antd);
    //挂载
    const vm = app.mount("#app-outlet");
</script>
{include "INC_footer.html"}